# -*- coding: utf-8 -*-
# @Time: 2021/11/27 14:55
# @Author: lijinxi
# @File    : availability_acceptance.py
# @desc


# -*- encoding: utf-8 -*-
# @Author：lijinxi
# @Time ：2021/3/20 19:33
# @File：plt_primary_ratio.py

# -*- encoding: utf-8 -*-
# @Author：lijinxi
# @Time ：2021/3/20 18:11
# @File：plt_capacity_ratio.py

import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
from matplotlib.ticker import MultipleLocator
from scipy.interpolate import make_interp_spline

mpl.rcParams["axes.unicode_minus"] = False

X = [i for i in range(5)]
Y1 = [1, 0.98, 0.73, 0.6, 0.6]
Y2 = [1, 0.79, 0.60, 0.53, 0.52]

plt.plot(X, Y1, ls='--', color='g', linewidth=2, marker='D', markersize=10, markerfacecolor='none')
plt.plot(X, Y2, ls='--', color='r', linewidth=2, marker='v', markersize=10, markerfacecolor='none')
# plt.title('Squares',fontsize=24)
plt.tick_params(axis='both', which='major', labelsize=18)
plt.xlabel(r'Availability Level', fontsize=18)
plt.ylabel('Acceptance Ratio', fontsize=18)
x_major_locator = MultipleLocator(1)
y_major_locator = MultipleLocator(0.1)
ax = plt.gca()
ax.xaxis.set_major_locator(x_major_locator)
ax.yaxis.set_major_locator(y_major_locator)
plt.xlim(-0.1, 4.2)
plt.ylim(0.4, 1)
plt.yticks([0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1])
plt.xticks([0, 1, 2, 3, 4], ['1\'9', "2'9s", "3'9s", "4'9s", "5'9s"])
plt.legend(['NBS', 'KSP(K=3)'], frameon=False, fontsize=18)
plt.axhline(y=0.5, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=0.6, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=0.7, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=0.8, color='lightgray', ls=':', linewidth=1)
plt.axhline(y=0.9, color='lightgray', ls=':', linewidth=1)
plt.savefig('acceptance_availability.pdf', bbox_inches='tight')
plt.show()
